package com.w.m.model;


import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Person implements InitializingBean {
	private String name;
	private Integer age;

	public String getName() {
		return name;
	}

	//获取环境变量
	@Value(value = "${JAVA_HOME}")//从本机系统环境变量中获取变量参数
	public void setName(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public Person() {
		System.out.println("Person be created@@@@!!!");
	}

	@Override
	public String toString() {
		return "Person{" +
				"name='" + name + '\'' +
				", age=" + age +
				'}';
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("Person afterPropertiesSet()");//spring 向外暴露实例的最后一步封装，可以由开发人员自动注入参数
	}
}
